import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA
 * Description
 * User:user
 * Date:2021-10-14
 * Time:14:13
 *
 */


public class HomeWork {
    /*
    public static void game(){
        Random random = new Random();
        int num = random.nextInt(100) + 1;[1-100)
        Scanner scan = new Scanner(System.in);
        while (scan.hasNextInt()){
            int guess = scan.nextInt();
            if(guess < num){
                System.out.println("小了");
            }else if(guess == num){
                System.out.println("找到了");
                break;
            }else{
                System.out.println("大了");
            }
        }
    }

    public static void main(String[] args) {
        game();
    }
*/


  /*  假定的是逆序输出数字的每一位，如果要做到顺序输出需要使用的是递归
    public static void fun(int n){
        int i = 0;
        while(n!=0){
            i = n % 10;
            System.out.println(i);
            n = n / 10;
        }
    }

    public static void main(String[] args) {
        fun(189);
    }

*/


/*
    //获取二进制中所有的偶数位和奇数位
    //分析：如果是32位，每一位的下标位31---0
    //偶数位为 31 ，每次 减去2 与上1进行输出
    public static  void fun(int n){
        for(int i = 31;i >= 0;i -= 2){
            System.out.print(((n>>i)&1) + " ");
        }
        System.out.println("");
        for(int i = 30;i >= 0;i -= 2){
            System.out.print(((n>>i)&1) + " ");
        }
    }

    public static void main(String[] args) {
        fun(11);
    }
*/






/*  //7 & 6
    //6 & 5
    //4 & 3
    //每次按位与得到的结果为与n-1再进行与，与的次数就是就是总次数
    public static int fun(int n){
        int count = 0;
        while(n != 0){
            n = n & (n - 1);
            count++;
        }
        return count;
    }
    public static void main(String[] args) {
        System.out.println(fun(-1));//32
        System.out.println(fun(7));//3
        System.out.println(fun(11));//3
    }
 */






/*
    //写一个函数返回参数二进制中的1的个数 比如：15000001 2个1
    //算法的优化，不再是每次都要比较32次，移动过程不一定非要移动32次，在x位时整个数已经为0
    //x次当中肯定有非0和为0的一部分
    public static int fun(int n){
        int count = 0;
        //右移的过程中可能已经为0了就不再需要右移了
       while(n != 0) {
            if((n&1) == 1){
                count++;
            }
            n = n>>>1;
        }
        return count;
    }
    public static void main(String[] args) {
        System.out.println(fun(-1));//32
        System.out.println(fun(7));//3
        System.out.println(fun(11));//3
    }

*/



/*
    //写一个函数返回参数二进制中的1的个数 比如：15000001 2个1
    public static int fun(int n){
        int count = 0;
        for (int i = 0; i < 32 ; i++) {
            if(((n>>>i)&1) == 1){
                count++;
            }
        }
        return count;
    }
    public static void main(String[] args) {
        System.out.println(fun(-1));//32
        System.out.println(fun(7));//3
    }
*/

/*

    //三次输入密码，判断是否输入错误
    public static void login(){
        Scanner scan = new Scanner(System.in);
        int count = 3;
        while(count != 0){
            System.out.println("请输入你的密码：");
            String pass = scan.nextLine();
            //字符串比较函数
            if(pass.equals("123456")){      
                System.out.println("输入成功");
                break;
            }else{
                count--;
                System.out.println("输入错误，请重新输入,您还有"+count+"次机会" );
            }
        }
        if(count == 0){
            System.out.println("你没有机会了");
        }
    }
    public static void main(String[] args) {
        login();
    }

*/



/*    //求水仙花数0---999999
    //数字为每个数字的数字总位数次方个
    public static void fun(int n) {
        for (int i = 0; i <= n ; i++) {
            int count = 0;
            int sum = 0;
            //找到替罪羊去除，因为后面还会计算每一位的值
            int tmp = i; 
            //求出数字的总位数
            while(tmp != 0){
                count++;
                tmp = tmp / 10;
            }
            tmp = i;
            //求出每一位的数字的位数次方的和
            while(tmp != 0){
            	 //pow返回值为double,计算的是tmp的count次方
                int v = (int)Math.pow(tmp % 10,count); 
                sum += v;
                tmp /= 10;

            }
            if(sum == i){
                System.out.println(i);

            }
        }
    }

    public static void main(String[] args) {
        fun(999999);

    }*/




/*
    //编写程序数一下1-100之间总共出现了多少个数字9
    //9 19 29 39 49 59 69 79 89 99
    //90 91 92 93 94 95 96 97 98 99
    //有多少个数字有9是19个，有多少个9是20个
    //分析：要么是个位上是9要么是十位上有9
    public static int  nineOfNum(int n) {
        int count = 0;
        for (int i = 1; i <= n; i++) {
            if(i % 10 == 9){
                count++;
            }
            if(i / 10 == 9){
                count++;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        System.out.println(nineOfNum(100));

    }
*/



/*
    public static double sum(int n) {
        double sum = 0;
        int flag = 1;
        for (int i = 1; i <= n ; i++) {
            sum += flag * 1.0 / i;
            flag = -flag;
        }
        return sum;
    }

    public static void main(String[] args) {
        double ret = sum(100);
        System.out.println(ret);
        System.out.println(sum(10));

    }*/




    /*public static void print(int n){
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n ; j++) {
                if(i == j){
                    System.out.print("*");
                }else if( i + j == n - 1){
                    System.out.print("*");
                }else{
                    System.out.print(" ");
                }
            }
            System.out.println("");
        }
    }
    public static void main2(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNextInt()){
            int n = scan.nextInt();
            print(n);
        }
    }*/
    public static void main1(String[] args) {
        //打印星号图形
        Scanner scan = new Scanner(System.in);
        while(scan.hasNextInt()){
            int n = scan.nextInt();
            for(int i = 0;i < n;i++){
                for (int j = 0; j < n ; j++) {
                    if(i == j){
                        System.out.print("*");
                    }else if(i + j == n -1){
                        System.out.print("*");
                    }else{
                        System.out.print(" ");
                    }
                }
                System.out.println("");
            }

        }
    }

}
